<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统日志</title>
<script type="text/javascript">
	//初始化checkbox
	jQuery("document").ready(function(){
		jQuery("#all").click(function(){
				var flag = document.getElementById("all").checked;
		   	 	jQuery("[name=selId]:checkbox").each(function() {
		        		jQuery(this).attr("checked", flag);
		   		});
	   })
	   $("#Pagination").paginate({
			count 		: '${count}',	//页数
			start 		: '${currentPageNo}',
			display     : 10,
			border					: true,
			border_color			: '#BEF8B8',
			text_color  			: '#68BA64',
			background_color    	: '#CAE8EA',	
			border_hover_color		: '#68BA64',
			text_hover_color  		: 'black',
			background_hover_color	: '#CAE8EA', 
			rotate      : false,
			images		: false,
			mouse		: 'press',
			onChange     			: function(page){
										document.fm.action=ctx+'/syslog/findByDate?currentPageNo='+page+'&currentPageNo='+'${currentPageNo}';
										document.fm.submit();
									  }
		});
		   if($.inArray("系统日志_删除", allRights)>=0){
			   $("#delete").show();
			   $("a[name='delete1']").show();
		   }
		   if($.inArray("系统日志_查询", allRights)>=0){
			   $("#search").show();
		   }
		   if($.inArray("系统日志_删除全部", allRights)>=0){
			   $("#deleteAll").show();
		   }
	});
	
	function deleteAllLog(){
		if(window.confirm("确认删除日志?")){
			var chk_value =[];
			$('input[name="selId"]:checked').each(function(){    
					chk_value.push(jQuery(this).val());
			});
			var selIds = chk_value.join();
			if(selIds==''){
				alert("请选择要删除的日志!");
				return;
			}
			var url = '${pageContext.request.contextPath}/syslog/deleteAll';
			url+= '?selIds='+selIds;
			document.fm.action = url;
			document.fm.submit();
		}
	}
	
	function allDelete(){
		if(window.confirm("确认删除全部日志?")){
			var url = '${pageContext.request.contextPath}/syslog/delete';
			document.fm.action = url;
			document.fm.submit();
		}
	}
	function search(){
		document.fm.action ='${pageContext.request.contextPath}/syslog/findByDate';
		document.fm.submit();
	}
</script>
</head>
<body>
<div>
	<form name="fm" action="" method="post">
		开始时间:<input class="Wdate" name="startDate" type="text" value="<fmt:formatDate value="${startDate}" type="date" pattern="yyyy-MM-dd"/>" onclick="WdatePicker();"/> 
		结束时间:<input class="Wdate" name="endDate" type="text" value="<fmt:formatDate value="${endDate}" type="date" pattern="yyyy-MM-dd"/>" onclick="WdatePicker();"/>
		<input id="search" style="display: none" type="submit" value="查询"/>
		<input id="delete" style="display: none" type="button" value="删除" onclick="deleteAllLog()"/>		 
		<input id="deleteAll" style="display: none" type="button" value="删除全部" onclick="allDelete()"/>		
	</form>
	
</div>
<table id="mytable" cellspacing="0" summary="The technical specifications of the Apple PowerMac G5 series">  
  <tr>
  	<th><input type="checkbox" id="all" name="all"/></th> 
    <th>序号</th> 
    <th>模块</th> 
    <th>操作内容</th> 
    <th>结果</th>
    <th>操作人</th>
    <th>IP地址</th>
    <th>日期</th>
    <th>操作</th> 
  </tr> 
  <c:forEach items="${syslogs}" var="syslog" varStatus="status">
  	<tr> 
	    <td align="center"><input type="checkbox" id="selId" name="selId" value="${syslog.id}"/></td> 
	   	<td>${status.index+1}</td>
	    <td>${syslog.moduleName}</td> 
	    <td>${syslog.operation}</td>
	    <td>${syslog.result==1?"成功":"失败"}</td> 
	    <td>${syslog.userName}</td> 
	    <td>${syslog.macAddress}</td> 
	    <td><fmt:formatDate value="${syslog.operDate}" type="date" pattern="yyyy-MM-dd HH:mm:ss"/></td>
	    <td><a name="delete1" style="display: none" href="${pageContext.request.contextPath}/syslog/deleteAll?selIds=${syslog.id}" onclick="{if(confirm('确定要删除吗?')){return true;}return false;}">删除</a></td> 
  	</tr> 
  </c:forEach>
</table>
<div id="Pagination" ></div> 
</body>
</html>
